package prac10;
import java.lang.*;
import java.io.*;
import java.util.*;

public class Frequency {

    public enum Freq {RARE, UNCOMMON, COMMON, UNKNOWN};
    public Freq value;

    public Frequency(int value) {
		switch (value) {
		    case 1: this.value = Freq.RARE;
			break;
		    case 2: this.value = Freq.UNCOMMON;
			break;
		    case 3: this.value = Freq.COMMON;
			break;
		    case 0: this.value = Freq.UNKNOWN;
			break;
		    default: System.out.println("Unrecognised frequency");
			this.value = Freq.UNKNOWN;
			break;
		}

    }

    public int getFrequency(){
		switch (value) {
	    	case RARE: return 1;
		    case UNCOMMON: return 2;
		    case COMMON: return 3;
		    case UNKNOWN: return 0;
	  	    default: System.out.println("ERROR"); // should never execute
			return -7;
		}
    }

    public String toString(){
	switch (value) {
    	    case RARE: return "Rare";
	    case UNCOMMON: return "Uncommon";
	    case COMMON: return "Common";
	    case UNKNOWN: return "Unknown";
  	    default: System.out.println("ERROR"); // should never execute
		return "ERROR";
	}
    }

}
